from win32com.client import Dispatch

# Get the running CATIA application instance
CATIA = Dispatch("CATIA.Application")

# Create a new part document
documents = CATIA.Documents
part_document = documents.Add("Part")


# Get the active part
part = part_document.Part

# Create a new sketch
sketches =  part.MainBody.Sketches
factory = part.Factory
origin_element = part.OriginElements
sketch = sketches.Add(origin_element.PlaneXY)

# Create a circle in the sketch
circle_center = factory.CreatePoint(0, 0, 0)
circle_radius = 50  # Radius of the circle in mm
circle = sketch.CreateCircle(circle_center, circle_radius)

# Create a pad using the sketch
extrudes = part.Extrudes
extrude = extrudes.Add(sketch, factory.CreateVector(0, 0, 10))  # Thickness of 10 mm

# Update the document to apply changes
part_document.Update()

print("Part document created, renamed, and a pad was added successfully.")
